package com.aaa.controller;

import com.aaa.entity.Singer;
import com.aaa.service.SingerService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
@CrossOrigin
@Controller
@RequestMapping("singer")
public class SingerController {
    @Resource
    SingerService singerService;
    @RequestMapping("selectAll")
    @ResponseBody
    public PageInfo select(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Singer> list = singerService.selectAll();
        PageInfo<Singer> personPageInfo = new PageInfo<>(list);
        return personPageInfo;
    }
    @RequestMapping("select")
    @ResponseBody
    public List<Singer> select(Integer searchId){
        return singerService.select(searchId);
    }
    @RequestMapping("add")
    @ResponseBody
    public Integer add(Singer singer){
        return singerService.add(singer);
    }
    @RequestMapping("update")
    @ResponseBody
    public Integer update(Singer singer){
        return singerService.update(singer);
    }
    @RequestMapping("delete")
    @ResponseBody
    public Integer delete(Integer id){
        return singerService.delete(id);
    }
}
